﻿using System;
using RestSharp;
using Ymatou.API.Common;
using Ymatou.Evaluate.Buyer.Model.ApiModel.Response.Query;
using Ymatou.ServiceCenter;

namespace Ymatou.Evaluate.Buyer.Model.ApiModel.Request.Query
{
    /// <summary>
    /// 获取商品评价汇总
    /// </summary>
    [Resource("bevaluateq.iapi.ymatou.com", "api/GetProductSummary", Method.GET, ParameterBuildType.UrlQueryString)]
    public class GetProductSummaryRequest : BaseRequestModel<GetProductSummaryResponse>
    {
        public override string ApiName { get { return "api/GetProductSummary"; } }
        public override bool HttpGet { get { return true; } }

        /// <summary>
        /// 商品Id
        /// </summary>
        public string ProductId { get; set; }

        public override void Validate()
        {
            const string errCode = "-1";
            if (string.IsNullOrWhiteSpace(ProductId))
            {
                throw new BussniessException(errCode, "商品Id不能为空");
            }
            Guid guid;
            ProductId = ProductId.Trim();
            if (!Guid.TryParse(ProductId, out guid))
            {
                throw new BussniessException(errCode, "商品Id非法");
            }

            base.Validate();
        }
    }
}
